package com.kunya.product.controller.portall;

import com.kunya.common.common.ServerResponse;
import com.kunya.common.util.CommonUtil;
import com.kunya.product.po.Question;
import com.kunya.product.service.active.IQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author WangGang
 * @Description: 商品提问controller
 * @date 2018/7/11 10:24
 */
@RestController
@RequestMapping("/question")
public class QuestionController {
    @Autowired
    private IQuestionService iQuestionService;
    /**
     * @Author WangGang
     * @Description 商品提问提交
     * @Date 10:25 2018/7/11
     **/
    @RequestMapping(value = "/create",method = RequestMethod.POST)
    public ServerResponse<Question> create(Question question,Long productId, HttpServletRequest httpServletRequest){
        return iQuestionService.insertQuestion(question,productId,"340_");
    }
    /**
     * @Author WangGang
     * @Description 通过商品ID查询商品提问列表
     * @Date 10:27 2018/7/11
     **/
    @RequestMapping(value = "/findList",method = RequestMethod.GET)
    public ServerResponse<List<Question>> findList(Long productId,HttpServletRequest httpServletRequest){
        return iQuestionService.listByProductId(productId,"340_");
    }
    /**
     * @Author WangGang
     * @Description 通过提问ID和商品ID查找商品提问详情
     * @Date 9:55 2018/7/12
     **/
    @RequestMapping(value = "/findDetails",method = RequestMethod.GET)
    public ServerResponse<Question> findDetails(Long questionId,Long productId,HttpServletRequest httpServletRequest){
        return iQuestionService.detailsByQuestionId(questionId,productId,"340_");
    }
}
